# 导包
import requests

# 创建封装模块的类
class LoginApi:

    # 登录接口实现封装
    def login(self,json_dict):
        url = "http://ihrm-test.itheima.net/api/sys/login"
        return requests.post(url=url,json=json_dict)   # 返回响应数据的值

    # 获取完整的token
    def get_token(self,json_dict):
        res = self.login(json_dict)
        res_json = res.json()
        token_value = res_json.get("data")
        token = "Bearer"+" "+ token_value
        return token

if __name__ == "__main__":
    login_api = LoginApi()
    json_dict = {"mobile": "13800000001", "password": "123456"}
    print(login_api.get_token(json_dict))




# if __name__ == "__main__":
#     # 实例化封装登录的类
#     login_api = LoginApi()
#     # 给变量赋值
#     json_dict = {"mobile":"13800000001","password":"123456"}
#     # 调用封装登录的方法，获取响应结果
#     res = login_api.login(json_dict)
#     # 将响应数据解析为json格式
#     print(res.json())
